<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        *{
            margin: 0;
        }
        div{
            box-sizing: border-box;
        }
        .container{
            overflow: hidden;
            display: flex;
            justify-content:space-between;
            flex-wrap: wrap;
            align-items: center;
            padding: 20px;
            background-color: #ccc;
        }
        .item{
            border: 1px solid #f00;
            width: 150px;
        }
        #item1{
            height: 120px;
        }
        #item2{
            height: 100px;
        }
        #item3{
            height: 40px;
        }
        #item4{
            height: 200px;
            border-color: #0f0;
        }
        @media all and (max-width: 640px){
            #item4{
                order: -1;
            }
            .container{
                align-items: flex-start;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <div class="item" id="item1"></div>
    <div class="item" id="item2"></div>
    <div class="item" id="item3"></div>
    <div class="item" id="item4"></div>
</div>
</body>
</html>